-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emit user_origin
for local login event
#52124
base: master
Are you sure you want to change the base?
Conversation
@@ -271,6 +271,11 @@ func (r *Reporter) run(ctx context.Context) { | |||
|
|||
return record | |||
} | |||
userRecordWithOrigin := func(userName string, v1AlphaUserKind prehogv1alpha.UserKind, v1AlphaUserOrigin prehogv1alpha.UserOrigin) *prehogv1.UserActivityRecord { | |||
record := userRecord(userName, v1AlphaUserKind) | |||
record.UserOrigin = prehogv1.UserOrigin(v1AlphaUserOrigin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting enum types here and below. I've put a note on the proto definition to keep the enum values in sync. Open for suggestion to implement explicit conversion.
@@ -161,7 +168,8 @@ func (a *Server) emitAuthAuditEvent(ctx context.Context, props authAuditProps) e | |||
Success: true, | |||
}, | |||
UserMetadata: apievents.UserMetadata{ | |||
User: props.username, | |||
User: props.username, | |||
UserOrigin: props.userOrigin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integer value will be reflected in the UI audit event. Not sold out on the alternative to use string field for audit event and the use int for the usage event. Open for suggestions.
I noticed we emit integer value for user_kind
field.
@@ -271,6 +271,17 @@ func (r *Reporter) run(ctx context.Context) { | |||
|
|||
return record | |||
} | |||
userRecordWithOrigin := func(userName string, v1AlphaUserKind prehogv1alpha.UserKind, v1AlphaUserOrigin prehogv1alpha.UserOrigin) *prehogv1.UserActivityRecord { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userRecordWithOrigin := func(userName string, v1AlphaUserKind prehogv1alpha.UserKind, v1AlphaUserOrigin prehogv1alpha.UserOrigin) *prehogv1.UserActivityRecord { | |
userRecordWithOrigin := func(userName string, kind prehogv1alpha.UserKind, origin prehogv1alpha.UserOrigin) *prehogv1.UserActivityRecord { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree the naming could be better but if you see line above, the userRecordWithOrigin
just wraps the userRecord
function with origin label. And the userRecord
uses the same function param names v1AlphaUserKind
. So imo its rather ideal to reuse the same param names rather than having two different terminology within a same method.
As part of Extend user activity report events with Identity events we want to emit user origin in user login event to distinguish user originated from Identity Governance related integration. This PR updates local user login event to include
user_origin
value and have them emitted in theUserActivityRecord
and theUserLogin
event.To pass the user origin value to the audit and usage event, new
user_login
field has been added toUserMetadata
type.The
UserMetadata
is included in many user related audit event, includingUserLogin
type that is emitted during local login. We set theuser_login
value only for theUserLogin
event.The origin label of the user resource metadata
teleport.dev/origin
is used to retrieve the origin value. If the label is not set, then we fall back to user type, which can belocal
orsso
.changelog: Updates local user login audit event to include
user_origin
field.Cloud prehog twin PR https://github.com/gravitational/cloud/pull/12092
Part of https://github.com/gravitational/teleport.e/issues/5946